""" -*- coding: utf-8 -*-"""
import os
from dotenv import load_dotenv

# 加载环境变量
load_dotenv()


class Config:
    # 数据库配置
    SQLALCHEMY_DATABASE_URI = os.getenv('DATABASE_URL', 'mysql+pymysql://root:root@localhost:3306/file_manager_db')
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # 文件上传配置
    UPLOAD_FOLDER = os.getenv('UPLOAD_FOLDER', 'f:/files')
    ALLOWED_EXTENSIONS = {'pdf', 'ppt','pptx', 'txt', 'doc', 'docx', 'xls', 'xlsx', 'jpg', 'jpeg', 'png', 'dwg'}
    MAX_CONTENT_LENGTH = 5 * 1024 * 1024 * 1024  # 5GB

    # 安全配置
    SECRET_KEY = os.getenv('SECRET_KEY', '@02367919876')

    # 角色定义
    ROLES = ['admin','designer', 'project_coordinator', 'project_assistant']

    @staticmethod
    def init_app(app):
        # 确保上传目录存在
        os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)


class DevelopmentConfig(Config):
    DEBUG = True


class ProductionConfig(Config):
    DEBUG = False


config = {
    'development': DevelopmentConfig,
    'production': ProductionConfig,
    'default': DevelopmentConfig
}